import { Controller, Get, Param, CacheTTL, Header } from '@nestjs/common';
import { WupingBusService } from './wupingbus.service';

@Controller()
export class WupingBusController {
  constructor(private readonly wupingbusService: WupingBusService) {}

  @Header('Access-Control-Allow-Origin', '*')
  @CacheTTL(86400)
  @Get('lineInfo/:line')
  getLineDetail(@Param('line') line) {
    return this.wupingbusService.getLineInfo(line);
  }

  @Header('Access-Control-Allow-Origin', '*')
  @CacheTTL(3)
  @Get('busInfo/:line')
  getBusLive(@Param('line') line: number) {
    return this.wupingbusService.getBusInfo(line);
  }

  @Header('Access-Control-Allow-Origin', '*')
  @CacheTTL(86400)
  @Get('allLineInfo')
  getAllLineInfo() {
    return this.wupingbusService.getAllLineInfo();
  }

  @Header('Access-Control-Allow-Origin', '*')
  @Get('searchBusLine/:name')
  searchBusLine(@Param('name') name: string) {
    return this.wupingbusService.searchBusLine(name);
  }

  @Header('Access-Control-Allow-Origin', '*')
  @Get('showBusOfStation/:name')
  showBusOfStation(@Param('name') name: string) {
    return this.wupingbusService.showBusOfStation(name);
  }
}
